<!DOCTYPE html>
<html>
<!-- Mirrored from www.zi-han.net/theme/hplus/login.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:18:23 GMT -->
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>乌托邦计划管理后台 - 登录</title>
    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="{{ asset('css/admin/bootstrap.min14ed.css?v=3.3.6') }}" rel="stylesheet">
    <link href="{{ asset('css/admin/font-awesome.min93e3.css?v=4.4.0') }}" rel="stylesheet">

    <link href="{{ asset('css/admin/animate.min.css') }}" rel="stylesheet">
    <link href="{{ asset('css/admin/style.min862f.css?v=4.1.0') }}" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    {{--<script>if(window.top !== window.self){ window.top.location = window.location;}</script>--}}
    <style>
        .captcha{
            background-color: #FFF;
            background-image: none;
            border: 1px solid #e5e6e7;
            border-radius: 1px;
            color: inherit;
            padding: 6px 12px;
            -webkit-transition: border-color .15s ease-in-out 0s,box-shadow .15s ease-in-out 0s;
            transition: border-color .15s ease-in-out 0s,box-shadow .15s ease-in-out 0s;
            width: 63%;
            font-size: 14px;
            height: 40px;
            margin-bottom: 5px;
        }
    </style>
</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <div>
            <div>

                <h1 class="logo-name">乌托邦</h1>

            </div>
            <h3>欢迎使用 乌托邦 管理后台</h3>

            <form class="m-t" role="form" id="login-form">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="用户名" required="" id="username" name="unit_login">
                </div>
                <div class="form-group">
                    <input type="password" class="form-control" placeholder="密码" required="" id="password" name="password">
                </div>
                <div>
                    <input type="text" class="captcha" placeholder="验证码" id="captcha" name="captcha">
                    <a href="javascript:void(0)" id="re_captcha"><img id="re_captcha_img" src="{{route("Api.Auth.captcha")}}" /></a>
                </div>
                <button type="button" class="btn btn-primary block full-width m-b" id="login-btn">登 录</button>
                </p>

            </form>
        </div>
    </div>
    <!-- Jquery -->
    <script src="{{url('js/jquery.min.js')}}"></script>
    <script>
        jQuery(function($) {

            $("#re_captcha").click(function () {
                var url = "{{route('Api.Auth.captcha')}}";
                var url = url + "?" + Math.random();
                $("#re_captcha_img").attr("src",url);
            });


            $('#login-btn').click(function(){
                var username = $('#username').val();
                var password = $('#password').val();
                var captcha = $('#captcha').val();

                $.ajax({
                    type:"post",
                    url:'{{route('Api.Admin.Auth.signInAdmin')}}',
                    dataType:"json",
                    data:{"username":username,"password":password,"captcha":captcha},
                    success:function(obj){
                        if(obj.level == "success"){
                            window.location.href="{{route('Admin.Home.planList')}}";
                        }else {
                            alert(obj.message);
                            $("#re_captcha").click();
                        }
                    },
                    error:function(obj){
                        var datajson = obj.responseJSON;
                        alert(datajson.message);
                    }
                });
            });

            $(document).keyup(function(event){
                if(event.keyCode ==13){
                    $("#login-btn").trigger("click");
                }
            });
        });
    </script>
</body>
</html>
